<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>스프링 게시판</title>
<link rel="stylesheet" href="../css/board.css" type="text/css">
<script type="text/javascript">
	function searchCheck(){
		if(document.search.keyWord.value==''){
			alert('검색어를 입력하세요');
			document.search.keyWord.focus();
			return false;
		}
	}
</script>
</head>
<body>
<br><br><br><br>
	<table align="center" width="70%" border="0" cellpadding="2" cellspacing="0">
		<tr bgcolor="#F3F3F3">
			<th width="50">번호</th>
			<th>제목</th>
			<th width="70">글쓴이</th>
			<th width="100">날짜</th>
			<th width="50">조회</th>
		</tr>
		<tr bgcolor="#777777">
			<td height="1" colspan="5"></td>
		</tr>
		<c:forEach var="article" items="${list}">
			<tr>
				<td align="center">${number} <c:set var="number"
						value="${number-1}" />
				</td>
				<td><a href="detail.do?seq=${article.seq}">${article.title}</a>
				</td>
				<td>${article.writer}</td>
				<td><fmt:formatDate value="${article.regdate}"
						pattern="yyyy년MM월dd일" /></td>
				<td>${article.hit}</td>
			</tr>
		</c:forEach>
		<c:if test="${count == 0}">
			<tr align="center">
				<td colspan="5">등록된 게시물이 없습니다.</td>
			</tr>
			<tr bgcolor="#777777">
				<td height="1" colspan="5"></td>
			</tr>
		</c:if>
		<tr>
			<td align="center" colspan="5">${pagingHtml}</td>
		</tr>
		<tr>
			<td align="right" colspan="5"><input type="button" value="글쓰기"
				class="inputb" onclick="location.href='write.do'"></td>
		</tr>
	</table>
	<form action="list.do" name="search" method="get"
		onsubmit="return searchCheck()">
		<table width="200" align="center" border="0" cellpadding="2"
			cellspacing="0">
			<tr>
				<td align="center"><select name="keyField">
						<option value="all">전체</option>
						<option value="writer">이름</option>
						<option value="content">내용</option>
				</select></td>

				<td><input type="text" size="16" name="keyWord"></td>
				<td><input type="submit" value="찾기"></td>
			</tr>
		</table>
	</form>
</body>
</html>